from django.db import models


class Images(models.Model):
    nid = models.AutoField(primary_key=True)
    name = models.CharField(max_length=128,verbose_name='名字')
    # pic = models.ImageField(upload_to='upload',default="/upload/default.jpg")
    pic=models.ImageField(upload_to='images',null=True,blank=True,verbose_name='案例图片')
    def __str__(self):
        return str(self.pic)

class Tools(models.Model):
    nid = models.AutoField(primary_key=True)
    name=models.CharField(max_length=128,verbose_name='名字')
    url=models.CharField(max_length=128,verbose_name='网址')
    desc=models.TextField(verbose_name='简介')
    def __str__(self):
        return self.name

class Blog(models.Model):
    nid = models.AutoField(primary_key=True)
    title=models.CharField(max_length=128,verbose_name='标题')
    img=models.ImageField(upload_to='blog',verbose_name='图片',null=True,blank=True)
    content=models.TextField(verbose_name='博客内容')
    author=models.CharField(max_length=128,verbose_name='作者')
    date=models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title

    class Meta:
        ordering = ['-date']
        verbose_name = '博客信息'